@extends('layouts.default')
@section('main')
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <link rel="stylesheet" href="/css/chosen.css" />
    <script type="text/javascript" src="/js/chosen.jquery.min.js"></script>
    <link rel="stylesheet" href="{{URL::asset('js/')}}/kindeditor-4.1.7/themes/default/default.css" />
    <link rel="stylesheet" href="{{URL::asset('js/')}}/kindeditor-4.1.7/plugins/code/prettify.css" />
    <script src="{{URL::asset('js/')}}/kindeditor-4.1.7/kindeditor.js" type="text/javascript"></script>
    <script charset="utf-8" src="{{URL::asset('js/')}}/kindeditor-4.1.7/lang/zh_CN.js"></script>
    <script charset="utf-8" src="{{URL::asset('js/')}}/kindeditor-4.1.7/plugins/code/prettify.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <script src="{{URL::asset('js/My97DatePicker/')}}/WdatePicker.js"></script>
    <script>
        KindEditor.ready(function(K) {

            var editor1 = K.create('#project_content,#project_invest_aim,#project_fund_plan,#project_team_advantage', {
                uploadJson: "{{url('kindedit/upload')}}",
                fileManagerJson: "{{url('kindedit/manager')}}",
                allowFileManager: true,
                afterBlur: function() {
                    this.sync();
                },
                items: ['source', '|', 'undo', 'redo', '|', 'cut', 'copy', 'paste', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', 'image', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'table', 'hr', 'emoticons', 'pagebreak', 'anchor', 'link', 'unlink', '|']
            });

        });
    </script>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a> <a href="{{url('project/index')}}" class="tip-bottom">项目管理</a> <a href="#" class="current">新增项目</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span7" style="width:80%;">
                    <div class="widget-box">
                        <div class="widget-title">
                        <span class="icon"> <i class="icon-align-justify"></i>
                        </span>
                            <h5>基础信息</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form  action="{{url('project/insert')}}" method="post" class="form-horizontal" id="projectForm" >

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>项目名称 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="subject" value=""   />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">副标题 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="title" value=""  />
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>项目阶段(新三板) :</label>
                                    <div class="controls">
                                        <select name="newthree_period" >
                                            <option value="">请选择</option>
                                            <option value="niguapai">拟挂牌</option>
                                            <option value="yiguapai">已挂牌</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>融资方式(新三板) :</label>
                                    <div class="controls">
                                        <select name="newthree_invest_way" >
                                            <option value="">请选择</option>
                                            <option value="xinsanbanjijin">新三板基金</option>
                                            <option value="dingxiangzengfa">定向增发</option>
                                            <option value="xingourengou">新股认购</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>退出机制 :</label>
                                    <div class="controls">
                                        <label> <input type="checkbox" name="out[]" value="pinggou" />并购退出</label>
                                        <label> <input type="checkbox" name="out[]" value="ipo" />IPO退出</label>
                                        <label> <input type="checkbox" name="out[]" value="zuoshi" />做市交易</label>
                                        <label> <input type="checkbox" name="out[]" value="huigou" />大股东回购</label>
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label class="control-label">融资目的 :</label>
                                    <div class="controls">
                                        <textarea id="project_invest_aim" name="invest_aim" style="width: 450px; height: 240px;"></textarea>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>行业分类 :</label>
                                    <div class="controls">
                                        @foreach($categories as $key => $category)
                                            <input type="checkbox" name="categories[]" value="{{ $key }}">&nbsp{{$category}}
                                        @endforeach
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">项目简介 :</label>
                                    <div class="controls">
                                        <textarea id="description" name="description" cols="150" rows="6" style="width:650px;"></textarea>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">内容 :</label>
                                    <div class="controls">
                                        <textarea id="project_content" name="content" style="width: 450px; height: 240px;"></textarea>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">列表页底图 :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="photo"
                                               placeholder="点击右边小图标上传列表页缩略图" />
                                        <img src="" width="120px" name="photo" height="120px"/>

                                        <a href="javascript:void(0);" id="uploadPhotoBtn"   onclick="javascript:openBrowse('uploadPhotoBtn','uploadPhoto');">点击上传(图片大小不小于h:285像素×w:150像素)</a>
                                        <input type="file" id="uploadPhoto" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadPhoto','photo')"/>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">详情页logo :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="big_image"
                                               placeholder="点击右边小图标上传推广大图" />
                                        <img src="" width="120px" name="big_image" height="120px"/>

                                        <a href="javascript:void(0);" id="uploadBimgBtn"   onclick="javascript:openBrowse('uploadBimgBtn','uploadBimg');">点击上传(图片大小不小于h:400像素×w:400像素)</a>
                                        <input type="file" id="uploadBimg" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadBimg','big_image')"/>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>所在地区 :</label>
                                    <div class="controls">
                                        <select id="city">
                                            <option value="0">省份</option>
                                            @foreach($zoneTree as $zone)
                                                <option value="{{$zone->id}}" >{{$zone->name}}</option>
                                            @endforeach
                                        </select>
                                        <select name="zone_id" id="zone">
                                            <option value="0">城市</option>

                                        </select>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">发布时间 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="pubdate" value="" placeholder="发布时间" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">用户姓名或手机号的一部分供模糊搜索 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="user_search" value="" placeholder="输入用户姓名或手机号的一部分，按下Enter键，搜索结果将出现在下面的多选框中，供选择" />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>项目拥有人 :</label>
                                    <div class="controls">
                                        <select name="uid" id="uid">
                                            <option value="0"></option>
                                            @foreach( $users as $key => $user )
                                                <option value="{{ $user->uid }}">{{ $user->realname or $user->nickname }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目开始时间 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="start_time" value="" placeholder="项目开始时间" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">排序 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="sort" value=""  />
                                    </div>
                                </div>

                                {{--<div class="control-group">--}}
                                    {{--<label class="control-label">联系人 :</label>--}}
                                    {{--<div class="controls">--}}
                                        {{--<input type="text" class="span11" name="contact" value=""  />--}}
                                    {{--</div>--}}
                                {{--</div>--}}

                                <div class="control-group">
                                    <label class="control-label">电话 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="phone" value=""  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">联系人地址 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="address" value=""  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">联系人Email :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="email" value=""  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">邮编 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="postcode" value=""  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">融资金额 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="invest_fund" value="" placeholder="单位：元"/>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">投资前估值 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="invest_value" value=""  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">出让股份 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="transfer_share" value=""  />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label"><span class="redD">*</span>资金用途(多选) :</label>
                                    <div class="controls">
                                        <select data-placeholder="资金用途（多选）" class="chzn-select" name="plans[]" multiple style="width:600px;" tabindex="4" id="dl_chose1">
                                            @foreach($plans as $v)
                                                <option value="{{$v->id}}">{{$v->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">团队优势 :</label>
                                    <div class="controls">
                                        <textarea id="project_team_advantage" name="team_advantage" style="width: 450px; height: 240px;"></textarea>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">团队规模 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="team_size" value=""   />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目评分 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="score" value=""   />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目月收入 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="month_income" value=""   />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">聊天群ID :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="groupid" value=""   />
                                    </div>
                                </div>


                                <div class="control-group">
                                    <label class="control-label">项目跟踪人 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="track_person" placeholder="项目跟踪人"   />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目风控措施 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="fengkong" placeholder="项目风控措施"   />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目做市商参与度 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="canyudu" placeholder="项目做市商参与度"   />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目做市商活跃度 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="huoyudu" placeholder="项目做市商活跃度"   />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">项目财务状况 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="caizheng" placeholder="项目财务状况"   />
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">上传商业计划书 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="bp_name"
                                               placeholder="点击右边小图标上传商业计划书" readonly />
                                        <input type="hidden" name="bp_filetype">
                                        <input type="hidden" name="bp_filesize">
                                        <input type="hidden" name="bp">

                                        <a href="javascript:void(0);" id="uploadBpBtn"   onclick="javascript:openBrowse('uploadBpBtn','uploadBp');"><i class="icon-upload"></i></a>
                                        <input type="file" id="uploadBp" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadBp','bp')"/>
                                    </div>
                                </div>

                                {{--<div class="control-group">--}}
                                    {{--<label class="control-label">商业计划书价格 :</label>--}}
                                    {{--<div class="controls">--}}
                                        {{--<input type="text" class="span11" name="bp_fileprize" placeholder="商业计划书价格"   />--}}
                                    {{--</div>--}}
                                {{--</div>--}}


                                <div class="widget-title">
                                    <span class="icon"> <i class="icon-align-justify"></i></span>
                                    <h5>状态选项</h5>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否推荐 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="recommend" value="1"   /> 是
                                        </label> <label> <input type="radio" name="recommend" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否热门 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="hot" value="1"  /> 是
                                        </label> <label> <input type="radio" name="hot" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否置顶 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="stick" value="1" /> 是
                                        </label> <label> <input type="radio" name="stick" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否头条 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="top" value="1" /> 是
                                        </label> <label> <input type="radio" name="top" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否路演 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="is_roadshow" value="1"  /> 是
                                        </label> <label> <input type="radio" name="is_roadshow" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否向投资人公开 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="open_to_investor" value="1" checked="checked"  /> 是
                                        </label> <label> <input type="radio" name="open_to_investor" value="0"  /> 否
                                        </label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">状态 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="status" value="1" checked="checked" /> 审核通过</label>
                                        <label> <input type="radio" name="status" value="0" /> 审核中</label>
                                        <label> <input type="radio" name="status" value="2" /> 审核不通过</label>
                                        <label> <input type="radio" name="status" value="-1" /> 禁用</label>
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label">是否明星项目 :</label>
                                    <div class="controls">
                                        <label> <input type="radio" name="star" value="1"  /> 是
                                        </label> <label> <input type="radio" name="star" value="0" checked="checked" /> 否
                                        </label>
                                    </div>
                                </div>
                                <div class="form-actions">
                                    <button type="button" class="btn btn-success" id="doSave">确认创建</button>
                                    <input type="hidden" class="span11" name="type" value="newthree"   />
                                </div>
                            </form>
                        </div>

                    </div>
                </div>
            </div>
        </div>

        <script>
            $(document).ready(function(){
                //初始化
                $(".chzn-select").chosen();

            });

            $("input[name='user_search']").keydown(function(event) {
                if (event.which == "13"){
                    var param = {};
                    param['user_search'] = $(this).val();
                    ajaxRequest(param, '/project/user-search', function (data) {
                        if (data.status) {
                            var html = '<option value="">请选择</option>';
                            $.each(data.message, function (i, n) {
                                if(n.realname){
                                    html += "<option value='" + n.uid + "'>" + n.realname + "</option>";
                                }else{
                                    html += "<option value='" + n.uid + "'>" + n.nickname + "</option>";
                                }
                            });
                            $("#uid").html(html);
                            alert('恭喜，已经生成选项,请选择所需要的用户');
                        } else {
                            var html = '<option value="">请按上面输入框的说明生成选项</option>';
                            $("#uid").html(html);
                            alert(data.message);
                        }
                    });
                }
            });

            $("#doSave").click(function(){
                $(this).attr('disabled','disabled');

                var project_content = $("#project_content").html();
                $("input[name='content']").val(project_content);
                ajaxRequest($('#projectForm').serializeArray(),$('#projectForm').attr('action'),function(data){
                    if(data.status){
                        alert(data.message);
                        window.location.href = data.forwardUrl;
                    }else{
                        $("#doSave").removeAttr('disabled');

                        alert(data.message);
                    }
                });
            });

            $("#city").change(function() {
                $("#zone").empty();
                $.post("{{url('zone/children')}}", {
                    id: $(this).val()
                }, function(data) {
                    if (data.status) {
                        var html = '<option value="0">城市</option>';
                        $.each(data.message, function(i, n) {
                            html += "<option value='"+n.id+"'>"+n.name+"</option>";
                        });
                        $("#zone").html(html);
                    }
                }, 'json');
            });
        </script>
@stop
